<template>
  <div>
    <Plan />
    <!-- 侧边栏抽屉 -->
    <Drawer v-model="isDrawerShow" :info="drawList" />
    <!-- 问题计划 -->
  </div>
</template>
<script setup lang="ts">
import {
  ref,
  provide,
  onMounted,
  markRaw,
  reactive,
  onBeforeUnmount,
} from "vue";
import baTableClass from "@/utils/baTable";
import { baTableApi, operatorShowOff } from "@/utils/common"; // 导入表格api方法生成器
import { ProductionPlan } from "@/api/backend/index";
import TagVue from "./components/tag.vue";
import TagSearch from "@/components/tagSearch/index.vue";
import { useRoute, useRouter } from "vue-router";
import useCurrentInstance from "@/utils/useCurrentInstance";
import type { TableRow, TableColumn } from "@/utils/baTable"; //表格列行类型
import { useNavTabs } from "@/store/navTabs";
import { getDictData } from "@/utils/common";
import { useDictionary } from "@/store/backend/tool/dictionary";
import { useProductionPlan } from "@/store/backend/ProductionPlan/plan";
import { useBomM } from "@/store/backend/BomM/bomM";
import { useBomDict } from "@/store/backend/BomM/bomDict";
import { useFactoryStation } from "@/store/backend/FactoryM/stationInfo";
import { useProductionWorkOrder } from "@/store/backend/ProductionPlan/workOrder";
import Plan from "./planTable.vue";
import Drawer from "./components/aside.vue";
import { useDept } from "@/store/backend/SysM/dept";

const placeholder = ref<string>("模糊搜索");
const tableRef = ref();
const route = useRoute();
const router = useRouter();
const navTabs = useNavTabs();
const dictionary = useDictionary();
const plan = useProductionPlan();
const bom = useBomM();
const bomD = useBomDict();
const station = useFactoryStation();
const planOrder = useProductionWorkOrder();
const isDrawerShow = ref(false);
const dept = useDept();

let drawList = reactive({});

//全局事件总线
const { proxy } = useCurrentInstance();

// 双击查看工艺路线
// proxy.eventBus.on("toMonitor", (row: any) => {
//   console.log("双击查看工艺路线", row, row.id);
//   plan.$patch((state) => {
//     state.single = row;
//     state.planId = row.id;
//   });
// });

proxy.eventBus.on("Drawer", () => {
  console.log("触发Drawer");
  isDrawerShow.value = true;
});
onMounted(() => {});

onBeforeUnmount(() => {
  proxy.eventBus.off("Drawer");
});

// 实例化表格后，将 baTable 的实例提供给上下文
provide("dictionary", dictionary);
provide("plan", plan);
provide("bom", bom);
provide("bomD", bomD);
provide("station", station);
provide("dept", dept);
</script>
<style lang="scss" scoped>
.default-main {
  margin: 0px !important;
  margin-bottom: 30px !important;
}
</style>
